php forum
php mysql forum
php mysql smarty
 
Topic Options
#316341 - 11/20/07 10:38 AM [7.2.2] Random Adds
blaaskaak Offline
Enthusiast

Registered: 02/25/07
Posts: 329
Loc: The Netherlands
As requested at ubbcentral, random adds. It puts the contents of a random post in a set topic in a variabele that can be used in any template.

open /ubbthreads.php

find
Code:
require_once("libs/ubbthreads.inc.php");


add below:

Code:
$query = "
	SELECT POST_BODY 
	FROM {$config['TABLE_PREFIX']}POSTS 
	WHERE TOPIC_ID = 6317 
	      AND POST_BODY != ''
	order by rand() 
	limit 0,1
";
$sth = $dbh->do_query($query,__LINE__,__FILE__);
list($advertisement) = $dbh -> fetch_array($sth,__LINE,__FILE__);
$config['ADVERTISEMENT'] = $advertisement;


You need to replace the 6317 topic value to the topic you want your banners to come from.

Example use:

In a template, on any spot you want you can add {$config.ADVERTISEMENT} and it will be replaced with that random content from that topic.
_________________________

Top
#316342 - 11/20/07 01:05 PM Re: [7.2.2] Random Adds [Re: blaaskaak]
AllenAyres Offline

I type Like navaho

Registered: 03/10/00
Posts: 25580
Loc: Texas
One "Ad" per post in that topic?
_________________________
- Allen wavey
- What Drives You?

Top
#316344 - 11/20/07 02:16 PM Re: [7.2.2] Random Adds [Re: AllenAyres]
blaaskaak Offline
Enthusiast

Registered: 02/25/07
Posts: 329
Loc: The Netherlands
Yeppers...
_________________________

Top
#316346 - 11/20/07 07:02 PM Re: [7.2.2] Random Adds [Re: blaaskaak]
Gizmo Offline

Wizard

Registered: 01/10/00
Posts: 5354
Loc: Portland, OR, USA
too bad, i'd hate to have the same ad displayed three times on one page lol
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design & Development President
UBB.Threads: My UBBSkins, UBB.Sitemaps

Top
#316349 - 11/21/07 02:02 PM Re: [7.2.2] Random Adds [Re: Gizmo]
blaaskaak Offline
Enthusiast

Registered: 02/25/07
Posts: 329
Loc: The Netherlands
It's easy to extend to display guarenteed different ones. Just change the limit in the query, and use different variables.

That's the way I have it running at a client.
_________________________

Top



Moderator:  sirdude 
Latest Posts
[7.2.1] - Naked shoutbox
by bellaonline
05/05/12 05:00 PM
[7.x] Stop Forum Spam Integration v0.4
by bellaonline
05/05/12 03:53 PM
Shout Box

(Views)Popular Topics
Known public proxy servers 1689885
Integrated Index Page (IIP) 5.3.1 555705
Finished-[6.5.2] Games Arcade Deluxe v1.9 501236
Integrated Index Page (IIP) 5.1.1 415112
TLD Bv2.1 Released - Threads Links Directory 396822
[6.0x] Who's Online 4.0.0 [Finished] 389412
Finished-[6.5.1] Integrated Index Page (IIP) 6.5 330423
Q & A 298663
Slash UBB 266936
[6.3.x] [beta] Hit Hack 2.0 227970
Forum Stats
13621 Members
59 Forums
37191 Topics
295716 Posts

Max Online: 686 @ 06/28/07 07:04 AM

 

 

 
fusionbb message board php hacks